package org.btik.light.mobile.ui.devs.camcar;

import android.view.View;
import android.widget.CompoundButton;
import org.btik.light.mobile.common.handler.SimpleController;
import org.btik.light.mobile.common.handler.SimpleSpeedController;
import org.btik.light.mobile.common.handler.adaptor.ClickerAdaptor;
import org.btik.light.mobile.common.handler.adaptor.DevBinderOnCheckedChangeListener;
import org.btik.light.mobile.common.handler.adaptor.SpeedHandler;
import org.btik.light.mobile.common.handler.adaptor.TurnEventHandler;

/**
 * @author lustre
 * @since 2023/4/8 9:53
 */
public interface CamCarHandlers {
    int CAR_GENERAL_OP = 1;
    String FORWARD = "0";
    String BACKWARD = "1";
    String TURN_LEFT = "2";
    String TURN_RIGHT = "3";
    String END_TURN_LEFT = "4";
    String END_TURN_RIGHT = "5";
    String STOP = "6";
    // 去吧，皮卡丘（设置速度为全速）
    String GO_PIKACHU = "7";

    int SPEED_OPT = 2;
    String SET_SPEED = "0";
    String MAX_SPEED = "100";

    /**
     * 摄像头操作
     */
    int CAM_GENERAL_OP = 3;

    String START_SEND = "0";

    String STOP_SEND = "1";

    String LED_ON = "2";

    String LED_OFF = "3";

    int CAM_SETTING_OP = 4;

    String SINGLE = "0";

    String OTHER = "1";

    String VERTICAL_FLIP = "11";

    String HORIZONTAL_MIRROR = "10";

    String STATUS_ON = "1";

    String STATUS_OFF = "0";
    /**
     * 速度控制
     */
    SpeedHandler SPEED_HANDLER = new SpeedHandler(new SimpleSpeedController(SPEED_OPT, SET_SPEED, MAX_SPEED),
            new SimpleController(CAR_GENERAL_OP, GO_PIKACHU));

    /**
     * 前
     */
    View.OnClickListener GO_FORWARD = new ClickerAdaptor(new SimpleController(CAR_GENERAL_OP, FORWARD));

    /**
     * 倒车
     */
    View.OnClickListener GO_BACKWARD = new ClickerAdaptor(new SimpleController(CAR_GENERAL_OP, BACKWARD));

    /**
     * 左转
     */
    View.OnTouchListener TO_TURN_LEFT = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, TURN_LEFT),
            new SimpleController(CAR_GENERAL_OP, END_TURN_LEFT));
    /**
     * 右转
     */
    View.OnTouchListener TO_TURN_RIGHT = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, TURN_RIGHT),
            new SimpleController(CAR_GENERAL_OP, END_TURN_RIGHT));

    /**
     * 停车
     */
    View.OnClickListener TO_STOP = new ClickerAdaptor(new SimpleController(CAR_GENERAL_OP, STOP));

    SimpleController VIDEO_ON = new SimpleController(CAM_GENERAL_OP, START_SEND);

    SimpleController VIDEO_0FF = new SimpleController(CAM_GENERAL_OP, STOP_SEND);

    SimpleController LIGHT_ON = new SimpleController(CAM_GENERAL_OP, LED_ON);

    SimpleController LIGHT_OFF = new SimpleController(CAM_GENERAL_OP, LED_OFF);

    CompoundButton.OnCheckedChangeListener VIDEO_SWITCH = new DevBinderOnCheckedChangeListener(VIDEO_ON, VIDEO_0FF);
    CompoundButton.OnCheckedChangeListener LIGHT_SWITCH = new DevBinderOnCheckedChangeListener(LIGHT_ON, LIGHT_OFF);

    CompoundButton.OnCheckedChangeListener VERTICAL_FLIP_SWITCH = new DevBinderOnCheckedChangeListener(
            new SimpleController(CAM_SETTING_OP, SINGLE, VERTICAL_FLIP, STATUS_ON),
            new SimpleController(CAM_SETTING_OP, SINGLE, VERTICAL_FLIP, STATUS_OFF)
    );

    CompoundButton.OnCheckedChangeListener HORIZONTAL_MIRROR_SWITCH = new DevBinderOnCheckedChangeListener(
            new SimpleController(CAM_SETTING_OP, SINGLE, HORIZONTAL_MIRROR, STATUS_ON),
            new SimpleController(CAM_SETTING_OP, SINGLE, HORIZONTAL_MIRROR, STATUS_OFF)
    );

    CamCarActionMeta LOCAL_META = new CamCarActionMeta()
            .setSpeedHandler(SPEED_HANDLER)
            .setGoBackward(GO_BACKWARD)
            .setGoForward(GO_FORWARD)
            .setToTurnLeft(TO_TURN_LEFT)
            .setToTurnRight(TO_TURN_RIGHT)
            .setToStop(TO_STOP)
            .setLightSwitch(LIGHT_SWITCH)
            .setLightOn(LIGHT_ON)
            .setVideoOff(LIGHT_OFF)
            .setVideoSwitch(VIDEO_SWITCH)
            .setVideoOn(VIDEO_ON)
            .setVideoOff(VIDEO_0FF)
            .setLightOff(LIGHT_OFF)
            .setVerticalFlip(VERTICAL_FLIP_SWITCH)
            .setHorizontalMirrorSwitch(HORIZONTAL_MIRROR_SWITCH);

}
